﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Media3D;


namespace GameBoard
{
    internal static class TranslucentMaterialMaker
    {
        internal static void MakeMaterialsFromBrush(Brush theBrush, ICanBeTranslucent target, bool isTransparent)
        {
            Brush transBrush = theBrush.Clone();
            transBrush.Opacity = .5;
            var invisBrush = theBrush.Clone();
            invisBrush.Opacity = 0.1;

            target.VisibleMaterial = new DiffuseMaterial(theBrush);
            target.TranslucentMaterial = new DiffuseMaterial(transBrush);
            target.InvisibleMaterial = new DiffuseMaterial(invisBrush);
            if (isTransparent)
            {
                target.Opacity = VisiblityType.Translucent;
            }
        }

        public static void ChangeCurrentMaterialTo(ICanBeTranslucent target, VisiblityType opacity)
        {
            switch (opacity)
            {
                case VisiblityType.Visible:
                    target.Material = target.VisibleMaterial;
                    target.BackMaterial = target.VisibleMaterial;
                    break;
                case VisiblityType.Invisible:
                    target.Material = target.InvisibleMaterial;
                    target.BackMaterial = target.InvisibleMaterial;
                    break;
                case VisiblityType.Translucent:
                    target.Material = target.TranslucentMaterial;
                    target.BackMaterial = target.TranslucentMaterial;
                    break;
            }

        }
    }
}
